#import "BWSymbolWindowController.h"
#import "BWGraphDocument.h"
#import "BWWrapList.h"

static BWSymbolWindowController *g_controller;


@implementation BWSymbolWindowController

- (void) dealloc
{
    [symbols release];
    [super dealloc];
} // dealloc


- (void) setDocument: (NSDocument *) document
{
    [super setDocument: document];

    // highlight the symbols in-use

} // setDocument


+ (NSString *) autosaveName
{
    return (@"symbolWindow");
} // autosaveName


+ (BWWindowController *) sharedInstance
{
    return (g_controller);
} // sharedInstance


+ (void) setSharedInstance: (BWWindowController *) controller
{
    assert ([[controller class] isSubclassOfClass: self]);

    g_controller = (BWSymbolWindowController *)controller;

} // setShraedInstance


+ (NSString *) windowNibName
{
    return (@"BWSymbolWindow");
} // windowNibName


- (void) setSymbols: (NSArray *) s
{
    [s retain];
    [symbols release];
    symbols = [s retain];

} // setSymbols


- (int) numberOfRowsInWrapList: (BWWrapList *) wrapList
{
    return ([symbols count]);
} // numberOfRowsInWrapList


- (id) wrapList: (BWWrapList *) list  objectForRow: (int) row
{
    return ([symbols objectAtIndex: row]);
} // objectForRow


- (void) windowDidLoad
{
    [super windowDidLoad];

    [wrapList bind: @"value"
              toObject: symbolController
              withKeyPath: @"arrangedObjects"
              options: nil];


    [wrapList bind: @"selection"
              toObject: symbolController
              withKeyPath: @"selection"
              options: nil];

} // windowDidLoad


+ (BWSymbolWindowController *) sharedController
{
    return ((BWSymbolWindowController *)[super sharedController]);
} // sharedController



- (NSString *) windowTitleForDocumentDisplayName: (NSString *) displayName
{
    return (@"Symbols");

} // windowTitleForDocumentDisplayName


@end // BWSymbolWindowController

